﻿// ***********************************************************************
// Assembly         : STX.Lib
// Author           : seven.x
// Created          : 12-26-2013
//
// Last Modified By : seven.x
// Last Modified On : 11-26-2013
// ***********************************************************************
// <copyright file="ReflectionExtensions.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

/// <summary>
/// The Reflection namespace.
/// </summary>
namespace System.Reflection
{
    /// <summary>
    /// Class ReflectionExtensions.
    /// </summary>
    public static class ReflectionExtensions
    {
        /// <summary>
        /// Automatics the dictionary.
        /// </summary>
        /// <param name="pis">The pis.</param>
        /// <param name="obj">The object.</param>
        /// <returns>IDictionary{System.StringSystem.String}.</returns>
        public static IDictionary<string, string> ToDict(this PropertyInfo[] pis,object obj)
        {
            IDictionary<string, string> dict = new Dictionary<string, string>();
            foreach (var pi in pis)
            {
                dict.Add(pi.Name, pi.GetValue(obj, null).ToString());
            }
            return dict;
        }
    }
}
